console.log('0')
import { createApp } from 'vue'
import App from './App.vue'
import router from './routers/index'
import pinia from './store'

// 权限路由
// import './permission'
import { registerElIcons } from '@/plugins/ElIcons'
// 引入全局组件布局
import PageWrapLayout from '@/components/PageWrapLayout/index.vue'

// svg-icons注册导入
import 'virtual:svg-icons-register'
import SvgIcon from '@/components/SvgIcon/index.vue' // svg component
// UI框架 element-plus
import ElementPlus from 'element-plus'
// 引入dayjs
import dayjs from 'dayjs'
import PropTable from '@/components/Table/PropTable/index.vue'

import 'element-plus/dist/index.css'
// 引入阿里图标库
import '@/assets/iconfont/iconfont.css'
import '@/assets/iconfont/iconfont.js'
//引入dayjs---------------------------------------------
import { useChangeColor } from '@/utils/theme'
const app = createApp(App)
registerElIcons(app)
app.config.globalProperties.$dayjs = dayjs
app.component('SvgIcon', SvgIcon)
app.component('PageWrapLayout', PageWrapLayout)
app.component('PropTable', PropTable)
app.use(pinia)
app.use(router)
app.use(ElementPlus).mount('#app')

const { getLightColor, getDarkColor } = useChangeColor()
/**
 * 切换主题颜色
 */
function changeThemeColor(color: string) {
  document.documentElement.style.setProperty('--el-color-primary', color)
  document.documentElement.style.setProperty('--el-color-primary-dark-2', `${getDarkColor(color, 0.1)}`)
  for (let i = 1; i <= 9; i++) {
    document.documentElement.style.setProperty(`--el-color-primary-light-${i}`, `${getLightColor(color, i / 10)}`)
  }
}
changeThemeColor('#f18d22')
